package net.lab1024.sa.admin.module.business.erp.inv.service;

import java.util.List;
import net.lab1024.sa.admin.module.business.erp.inv.dao.InventordDao;
import net.lab1024.sa.admin.module.business.erp.inv.domain.entity.InventordEntity;
import net.lab1024.sa.admin.module.business.erp.inv.domain.form.InventordAddForm;
import net.lab1024.sa.admin.module.business.erp.inv.domain.form.InventordQueryForm;
import net.lab1024.sa.admin.module.business.erp.inv.domain.form.InventordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.inv.domain.vo.InventordVO;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 暂收送检单行 Service
 *
 * @Author AKITA
 * @Date 2025-08-03 22:54:42
 * @Copyright AKITA
 */

@Service
public class InventordService {

    @Resource
    private InventordDao inventordDao;

    public PageResult<InventordVO> queryPage(InventordQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<InventordVO> list = inventordDao.queryPage(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);
    }

    public ResponseDTO<String> add(InventordAddForm addForm) {
        InventordEntity inventordEntity = SmartBeanUtil.copy(addForm, InventordEntity.class);
        inventordDao.insert(inventordEntity);
        return ResponseDTO.ok();
    }

    public ResponseDTO<String> update(InventordUpdateForm updateForm) {
        InventordEntity inventordEntity = SmartBeanUtil.copy(updateForm, InventordEntity.class);
        inventordDao.updateById(inventordEntity);
        return ResponseDTO.ok();
    }

    public ResponseDTO<String> batchDelete(List<Long> idList) {
        inventordDao.deleteBatchIds(idList);
        return ResponseDTO.ok();
    }

    public ResponseDTO<String> delete(Long id) {
        inventordDao.deleteById(id);
        return ResponseDTO.ok();
    }

    public PageResult<InventordVO> queryPageInOut(InventordQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<InventordVO> list = inventordDao.queryPageInOut(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);

    }
}
